<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    /* 先父后子 由外向内 */
    #father{
        width:200px;
        height:200px;
        background:black;
        padding:10px;
    }

    #child{
        width:100px;
        height:100px;
        background:green;
    }
</style>
<body>
    
    <div id="father">
        <div id="child"></div>
    </div>

    <script>
        document.getElementById("father").addEventListener("click",function(){
            alert("父级:"+this.id);
        },true);


        document.getElementById("child").addEventListener("click",function(){
            alert("子级:"+this.id);
        },true);
    </script>
</body>
</html>